﻿import kliment.display.Sprite;
import kliment.ui.ButtonAbstract;
import kliment.ui.menuAbstract.MenuAbstract;
/**
 * ...
 * @author	Kliment
 * @author	1.0.2
 */
class kliment.ui.menuAbstract.BackPathAbstract extends MenuAbstract {
	private var _elamentsList:Array;
	
	public function BackPathAbstract(target_mc:MovieClip, inteval:Number, isParent:Boolean) {
		super(target_mc, inteval, isParent);
		_elamentsList = new Array();
	}
	
	public function register(target:ButtonAbstract):Void {
		super.register(target);
		target.setFocus();
		_currentButton.buttonMode = true;
		_currentButton.resetFocus();
		_currentButton = target;
		_currentButton.buttonMode = false;
	}
	
	private function onRelease(target:ButtonAbstract):Void {
		if (target != _currentButton) {
			_currentButton = target;
			target.onRelease();
			_currentButton.resetFocus();
		}
	}
	
	private function onRollOver(target:ButtonAbstract):Void {
		if (target != _currentButton){
			target.setFocus();
			_currentButton.resetFocus();
		}
	}
	
	private function onRollOut(target:ButtonAbstract):Void {
		if (target != _currentButton){
			target.resetFocus();
			_currentButton.setFocus();
		}
	}
	
	private function onReleaseOutside(target:ButtonAbstract):Void {
		onRollOut(target);
	}
	
	public function remove():Void {
		var i:Number = _elamentsList.length;
		while (i--) {
			var item:Sprite = _elamentsList[i];
			item.remove();
		}
		delete _elamentsList;
		super.remove();
	}
}